export default {
	// 消息框
	toast(title){
		return uni.showToast({
			title: title,
			icon: 'none',
			duration: 2000
		})
	},
	height(){
		let height
		uni.getSystemInfo({
			success(res){
				// #ifdef MP-WEIXIN
				let custom = wx.getMenuButtonBoundingClientRect()
				height = custom.bottom + custom.top - res.statusBarHeight
				console.log(height)
				// #endif
			}
		})
		return height
	},
	// 赋值
	pageckForIn(ar1,ar2){
		Object.keys(ar1).forEach(key => {
			ar1[key] = ar2[key]
		})
		return ar1
	},
	// 验证手机号
	testifyMobile(mobile){
		let reg_tel = /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/
		return reg_tel.test(mobile)
	},
	objToArray(query = [], optins, filterKey){
		for(let key in optins){
			if(key != filterKey) query.push(`${key}=${optins[key]}`)
		}
		return query
	},
	// 方法定义 lat,lng 
	GetDistance( lat1,  lng1,  lat2,  lng2){
	    var radLat1 = lat1*Math.PI / 180.0;
	    var radLat2 = lat2*Math.PI / 180.0;
	    var a = radLat1 - radLat2;
	    var  b = lng1*Math.PI / 180.0 - lng2*Math.PI / 180.0;
	    var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a/2),2) +
	    Math.cos(radLat1)*Math.cos(radLat2)*Math.pow(Math.sin(b/2),2)));
	    s = s *6378.137 ;// EARTH_RADIUS;
	    s = Math.round(s * 10000) / 10000;
	    return s;
	}

}
